<?php defined("APP_VERSION") OR die("No Access"); ?>
<div class="modebox setup-box setup-detail">
  <div class="hd">
    <h3>详细信息</h3>
  </div>
  <div class="con">
    <p class="col-hints">为了让各位DPer了解你，以下信息将显示在个人资料页。</p>
    <div class="form-box">
      <form id="detailInfoForm" action="<?php echo $this->baseUrl('member', 'more') ?>" method="post">
        <ul>
          <li>
            <div class="tit">
              <label for="">体型：</label>
            </div>
            <div class="f-part">
              <div class="output-txt J_select" id="J_weight"><span class="J_txt">保密</span><i class="icon-tri-down"></i></div>
              <input name="bodily" value="0" id="bodily" type="hidden" />
            </div>
            <div class="f-msg"></div>
          </li>
          <li>
            <div class="tit">
              <label for="">恋爱状况：</label>
            </div>
            <div class="f-part f-iradio" id="love_status">
              <input name="loveStatus" class="radio-plain" value="1" id="love1" type="radio" />
              <label for="love1">单身</label>
              <input name="loveStatus" class="radio-plain" value="2" id="love2" type="radio" />
              <label for="love2">热恋</label>
              <input name="loveStatus" class="radio-plain" value="5" id="love5" type="radio" />
              <label for="love5">备婚</label>
              <input name="loveStatus" class="radio-plain" value="3" id="love3" type="radio" />
              <label for="love3">已婚</label>
              <input name="loveStatus" class="radio-plain" value="4" id="love4" type="radio" />
              <label for="love4">保密</label>
            </div>
            <div class="f-msg"></div>
          </li>
          <li style="display : none;">
            <div class="tit">
              <label for="">生日：</label>
            </div>
            <div class="f-part slt-box slt-birth">
              <div class="slt-year-box">
                <div class="output-txt J_select" id="J_year"><span class="J_txt"></span><i class="icon-tri-down"></i></div>
                <input name="birthYear" value="" type="hidden">
                <span>年</span> </div>
              <div class="slt-month-box">
                <div class="output-txt J_select" id="J_month"><span class="J_txt"></span><i class="icon-tri-down"></i></div>
                <input name="birthMonth" value="" type="hidden">
                <span>月</span> </div>
              <div class="slt-date-box">
                <div class="output-txt J_select" id="J_day"><span class="J_txt"></span><i class="icon-tri-down"></i></div>
                <input name="birthDay" value="" type="hidden">
                <span>日</span> </div>
            </div>
            <div class="f-msg"></div>
          </li>
          <li style="display : none;">
            <div class="tit">
              <label for="">星座：</label>
            </div>
            <div class="f-part">
              <div class="output-txt J_select" id="J_cons"><span class="J_txt"></span><i class="icon-tri-down"></i></div>
              <input name="constellation" value="" type="hidden">
            </div>
            <div class="f-msg"></div>
          </li>
          <li>
            <div class="tit">
              <label for="">QQ：</label>
            </div>
            <div class="f-part f-iradio">
              <input name="userQQ" id="userQQ" data-rules="qq" class="J_vad input-plain itxt-s" value="<?php echo $this->data['member']['qq'] ?>" type="text" />
              <input name="isQQPublic" class="radio-plain" value="true" id="qqpub1" type="radio" />
              <label for="qqpub1">公开</label>
              <input name="isQQPublic" class="radio-plain" value="false" checked="" id="qqpub2" type="radio" />
              <label for="qqpub2">保密</label>
            </div>
            <div class="f-msg"></div>
          </li>
          <li>
            <div class="tit">
              <label for="">MSN：</label>
            </div>
            <div class="f-part f-iradio">
              <input name="userMSN" id="userMSN" data-rules="msn" class="J_vad input-plain itxt-s" value="<?php echo $this->data['member']['msn'] ?>" type="text" />
              <input name="isMsnPublic" class="radio-plain" value="true" id="msnpub1" type="radio" />
              <label for="msnpub1">公开</label>
              <input name="isMsnPublic" class="radio-plain" value="false" checked="" id="msnpub2" type="radio" />
              <label for="msnpub2">保密</label>
            </div>
            <div class="f-msg"></div>
          </li>
          <li>
            <div class="tit">
              <label for="">行业/职业：</label>
            </div>
            <div class="f-part">
              <input name="job" id='job' placeholder="输入你所在的行业" data-rules="carre" class="J_ph J_vad input-plain itxt-s form-default" value="<?php echo $this->data['member']['hangye'] ?>" type="text" />
            </div>
            <div class="f-msg"></div>
          </li>
          <li>
            <div class="tit">
              <label for="">大学：</label>
            </div>
            <div class="f-part">
              <input id="university" name="university" data-rules="colle" class="J_vad input-plain itxt-s" value="<?php echo $this->data['member']['daxue'] ?>" type="text" />
            </div>
            <div class="f-msg"></div>
          </li>
          <li>
            <div class="tit">
              <label for="">高中：</label>
            </div>
            <div class="f-part">
              <input name="middleSchool" id="middleSchool" data-rules="high" class="J_vad input-plain itxt-s" value="<?php echo $this->data['member']['gaozhong'] ?>" type="text" />
            </div>
            <div class="f-msg"></div>
          </li>
          <li>
            <div class="tit">
              <label for="">个人主页：</label>
            </div>
            <div class="f-part">
              <input name="userHomePage" id="userHomePage" data-rules="www" class="J_vad input-plain itxt-l" value="<?php echo $this->data['member']['home_page'] ?>" type="text" />
            </div>
            <div class="f-msg tar-msg"></div>
          </li>
          <li>
            <div class="tit">
              <label for="">爱好：<span class="col-exp">0/30</span></label>
            </div>
            <div class="f-part">
              <textarea name="interest" id="interest" cols="" data-rules="favor" rows="2" class="J_ph J_vad tar-plain form-default" placeholder="如：睡觉、看书"><?php echo $this->data['member']['aihao'] ?></textarea>
            </div>
            <div class="f-msg tar-msg"></div>
          </li>
          <li>
            <div class="tit">
              <label for="">电影/导演/演员：<span class="col-exp">0/30</span></label>
            </div>
            <div class="f-part">
              <textarea name="movie" id="movie" cols="" rows="2" data-rules="movie" class="J_ph J_vad tar-plain form-default" placeholder="如：黑猫警长、谍影重重"><?php echo $this->data['member']['movie'] ?></textarea>
            </div>
            <div class="f-msg tar-msg"></div>
          </li>
          <li>
            <div class="tit">
              <label for="">音乐/歌曲/歌手：<span class="col-exp">0/30</span></label>
            </div>
            <div class="f-part">
              <textarea name="music" id="music" cols="" rows="2" data-rules="music" class="J_ph J_vad tar-plain form-default" placeholder="如：交响乐、最炫民族风"><?php echo $this->data['member']['music'] ?></textarea>
            </div>
            <div class="f-msg tar-msg"></div>
          </li>
          <li>
            <div class="tit">
              <label for="">书/作者：<span class="col-exp">0/30</span></label>
            </div>
            <div class="f-part">
              <textarea name="book" id="book" cols="" rows="2" data-rules="book" class="J_ph J_vad tar-plain form-default" placeholder="如：深夜食堂"><?php echo $this->data['member']['book'] ?></textarea>
            </div>
            <div class="f-msg tar-msg"></div>
          </li>
          <li>
            <div class="tit">
              <label for="">菜肴/菜系/餐馆：<span class="col-exp">0/30</span></label>
            </div>
            <div class="f-part">
              <textarea name="dish" id="dish" cols="" rows="2" data-rules="dish" class="J_ph J_vad tar-plain form-default" placeholder="如：川菜、甜食"><?php echo $this->data['member']['dish'] ?></textarea>
            </div>
            <div class="f-msg tar-msg"></div>
          </li>
        </ul>
        <div class="btn-box"> 
			<span class="medi-btn"><button class="btn-txt J_submit" id="J_mato" type="submit">保存</button></span>
		</div>
      </form>
    </div>
  </div>
</div>
<div class="pop-main pop-slt-box J_sltbox slt-body-type Hide" id="J_wlist">
<div class="slt-list"></div>
</div>
<script type="text/javascript">
	var tixing_obj = {
		id : 'J_weight',
		tixing : {0:'保密', 1: '清瘦', 2:'匀称', 3: '健壮', 4: '球形'},
		click : function() {
			if ($('#J_wlist').hasClass('Hide')) {
				x = $('#J_weight').offset().top;
				y = $('#J_weight').offset().left;
				x_top = parseInt(x)-64;
				y_left = parseInt(y)-193;
				$('#J_wlist').removeClass('Hide').css({'top':x_top+'px','left':y_left+'px'});
			} else {
				$('#J_wlist').addClass('Hide');
			}
		},
		click_li : function() {
			$('#J_wlist div').find('ul li').click(function(){
				$('#bodily').val($(this).attr('data-id'));
				$('#J_wlist').addClass('Hide');
				$('#J_weight').find('span').html($(this).html());
			});
		},
		init_tixing: function() {
			ul = '<ul>';
			for (o in tixing_obj.tixing) {
				ul += '<li data-id="'+o+'">'+tixing_obj.tixing[o]+'</li>';
			}
			ul += '</ul>';
			$('#J_wlist div').append(ul);
		}
	};
	$('#bodily').val("<?php echo $this->data['member']['tixing'] ?>");
	$('#J_weight').find('span').html(tixing_obj.tixing["<?php echo $this->data['member']['tixing'] ?>"]);
	$('#love_status').find('input').each(function(i) {
		if ($(this).val() == "<?php echo $this->data['member']['love_status'] ?>") {
			$(this).attr('checked', true);
		}
	});
	
	tixing_obj.init_tixing();
	document.getElementById(tixing_obj.id).onclick = tixing_obj.click;
	tixing_obj.click_li();
	
	var form_submit = {
		qq_id : 'userQQ',
		msn_id : 'userMSN',
		job_id : 'job',
		daxue_id : 'university',
		gaozhong_id : 'middleSchool',
		homepage_id : 'userHomePage',
		aihao_id : 'interest',
		movie_id : 'movie',
		music_id : 'music',
		book_id : 'book',
		dish_id : 'book',
		check_qq : function() {
			reponse = true;
			regobj = /^\d{5,12}$/;
			qqObj = $('#'+form_submit.qq_id);
			if (qqObj.val() != '' && !regobj.test(qqObj.val())) {
				reponse = false;
				qqObj.parent().next().removeClass('Hide').addClass('m-err').html('请填写正确的QQ号码.');
			} else {
				qqObj.parent().next().removeClass('m-err').addClass('Hide').html('');
			}
		
			return reponse;
		},
		check_msn : function() {
			reponse = true;
			regobj = /^[\w\-\.]+@[\w\-\.]+(\.\w+)+$/;
			msnObj = $('#'+form_submit.msn_id);
			if (msnObj.val() != '' && !regobj.test(msnObj.val())) {
				reponse = false;
				msnObj.parent().next().removeClass('Hide').addClass('m-err').html('请填写正确的MSN号码.');				
			} else {
				msnObj.parent().next().removeClass('m-err').addClass('Hide').html('');
			}
			
			return reponse;
		},
		check_job : function() {
			reponse = true;
			regObj = /^[a-zA-Z0-9\u4e00-\u9fa5]{1,30}$/;
			jobObj = $('#'+form_submit.job_id);
			if (jobObj.val() != '' && !regObj.test(jobObj.val())) {
				reponse = false;
				jobObj.parent().next().removeClass('Hide').addClass('m-err').html('请填输入30个以内的字符.');
			} else {
				jobObj.parent().next().removeClass('m-err').addClass('Hide').html('');
			}
			
			return reponse;
		},
		check_daxue : function() {
			reponse = true;
			regObj = /^[a-zA-Z0-9\u4e00-\u9fa5]{1,30}$/;
			daxueObj = $('#'+form_submit.daxue_id);
			if (daxueObj.val() != '' && !regObj.test(daxueObj.val())) {
				reponse = false;
				daxueObj.parent().next().removeClass('Hide').addClass('m-err').html('请填输入30个以内的字符.');
			} else {
				daxueObj.parent().next().removeClass('m-err').addClass('Hide').html('');
			}
			
			return reponse;
		},
		check_gaozhong : function () {
			reponse = true;
			regObj = /^[a-zA-Z0-9\u4e00-\u9fa5]{1,30}$/;
			gaozhongObj = $('#'+form_submit.gaozhong_id);
			if (gaozhongObj.val() != '' && !regObj.test(gaozhongObj.val())) {
				reponse = false;
				gaozhongObj.parent().next().removeClass('Hide').addClass('m-err').html('请填输入30个以内的字符.');
			} else {
				gaozhongObj.parent().next().removeClass('m-err').addClass('Hide').html('');
			}
			
			return reponse;
		},
		check_homepage : function() {
			reponse = true;
			regObj = /^(\w+\.)+?[a-zA-Z]{2,3}$/;
			homepageObj = $('#'+form_submit.homepage_id);
			if (homepageObj.val() != '' && !regObj.test(homepageObj.val())) {
				reponse = false;
				homepageObj.parent().next().removeClass('Hide').addClass('m-err').html('请填输入正确的域名,如www.miaomiaomiao.net.');
			} else {
				homepageObj.parent().next().removeClass('m-err').addClass('Hide').html('');
			}
			
			return reponse;
		},
		check_aihao : function() {
			reponse = true;
			regObj = /^[a-zA-Z0-9\u4e00-\u9fa5]{1,30}$/;
			aihaoObj = $('#'+form_submit.aihao_id);
			if (aihaoObj.val() != '' && !regObj.test(aihaoObj.val())) {
				reponse = false;
				aihaoObj.parent().next().removeClass('Hide').addClass('m-err').html('请填输入30个以内的字符.');
			} else {
				aihaoObj.parent().next().removeClass('m-err').addClass('Hide').html('');
			}
			
			return reponse;
		},
		check_movie : function() {
			reponse = true;
			regObj = /^[a-zA-Z0-9\u4e00-\u9fa5]{1,30}$/;
			moveObj = $('#'+form_submit.movie_id);
			if (moveObj.val() != '' && !regObj.test(moveObj.val())) {
				reponse = false;
				moveObj.parent().next().removeClass('Hide').addClass('m-err').html('请填输入30个以内的字符.');
			} else {
				moveObj.parent().next().removeClass('m-err').addClass('Hide').html('');
			}
			
			return reponse;
		},
		check_music: function() {
			reponse = true;
			regObj = /^[a-zA-Z0-9\u4e00-\u9fa5]{1,30}$/;
			musicObj = $('#'+form_submit.music_id);
			if (musicObj.val() != '' && !regObj.test(musicObj.val())) {
				reponse = false;
				musicObj.parent().next().removeClass('Hide').addClass('m-err').html('请填输入30个以内的字符.');			
			} else {
				musicObj.parent().next().removeClass('m-err').addClass('Hide').html('');
			}
			
			return reponse;
		},
		check_book:function() {
			reponse = true;
			regObj = /^[a-zA-Z0-9\u4e00-\u9fa5]{1,30}$/;
			bookObj = $('#'+form_submit.book_id);
			if (bookObj.val() != '' && !regObj.test(bookObj.val())) {
				reponse = false;
				bookObj.parent().next().removeClass('Hide').addClass('m-err').html('请填输入30个以内的字符.');
			} else {
				bookObj.parent().next().removeClass('m-err').addClass('Hide').html('');
			}
			
			return reponse;
		},
		check_dish:function() {
			reponse = true;
			regObj = /^[a-zA-Z0-9\u4e00-\u9fa5]{1,30}$/;
			dishObj = $('#'+form_submit.dish_id);
			if (dishObj.val() != '' && !regObj.test(dishObj.val())) {
				reponse = false;
				dishObj.parent().next().removeClass('Hide').addClass('m-err').html('请填输入30个以内的字符.');
			} else {
				dishObj.parent().next().removeClass('m-err').addClass('Hide').html('');
			}
			
			return reponse;
		},
		init_check : function() {
			document.getElementById(form_submit.qq_id).onblur = form_submit.check_qq;
			document.getElementById(form_submit.msn_id).onblur = form_submit.check_msn;
			document.getElementById(form_submit.job_id).onblur = form_submit.check_job;
			document.getElementById(form_submit.daxue_id).onblur = form_submit.check_daxue;
			document.getElementById(form_submit.homepage_id).onblur = form_submit.check_homepage;
			document.getElementById(form_submit.aihao_id).onblur = form_submit.check_aihao;
			document.getElementById(form_submit.movie_id).onblur = form_submit.check_movie;
			document.getElementById(form_submit.music_id).onblur = form_submit.check_music;
			document.getElementById(form_submit.book_id).onblur = form_submit.check_book;
			document.getElementById(form_submit.dish_id).onblur = form_submit.check_dish;
		}
	};
	form_submit.init_check();
	
	$('#detailInfoForm').submit(function() {
		submit = true;
		if (!form_submit.check_qq()) {
			submit = false;
		}
		
		if (!form_submit.check_msn()) {
			submit = false;
		}
		
		if (!form_submit.check_job()) {
			submit = false;
		}
		
		if (!form_submit.check_daxue()) {
			submit = false;
		}
		
		if (!form_submit.check_homepage()) {
			submit = false;
		}
		
		if (!form_submit.check_aihao()) {
			submit = false;
		}
		
		if (!form_submit.check_movie()) {
			submit = false;
		}
		
		if (!form_submit.check_music()) {
			submit = false;
		}
		
		if (!form_submit.check_book()) {
			submit = false;
		}
		
		if (!form_submit.check_dish()) {
			submit = false;
		}
		
		if (submit) {
			form_waitting('表单正在提交,请稍等...');
			$.post($(this).attr('action'), $(this).serialize(), function(reponse) {
				close_from_waitting();
				reponse = eval('('+reponse+')');
				if (reponse.code == 0) {
					form_success(reponse.message);
					$('#member-main').load('<?php echo $this->baseUrl("member", "more");?>');
				} else {
					alert(reponse.message);
				}
			});
		}
		
		return false;
	});
</script>